(function(angular) {
	'use strict';
	angular.module("fs.waf").factory("ppfRepaymentService", ppfRepaymentService);
	ppfRepaymentService.$inject = [ '$q', 'loggerFactory', 'commonService', 'ajaxServiceFactory' ];
	function ppfRepaymentService($q, loggerFactory, commonService, ajaxServiceFactory) {
		var log = loggerFactory.getLogger("ppfRepaymentService");
		var ajaxService = ajaxServiceFactory.buildAjaxService({
			getCurrencyOptions : {
				url : 'do/cda/dataList/currenciesBySiteCode',
				method : 'get'
			},
			getPpfRepaymentLoadStatusOptions : {
				url : 'do/lfe/dataList/ppfRepaymentLoadStatus',
				method : 'get'
			},
			getPpfRepaymentStatusOptions : {
				url : 'do/lfe/dataList/ppfRepaymentStatus',
				method : 'get'
			},
			getPpfRepaymentsInProcing : {
				url : 'do/lfe/ppfRepayment/ppfRepaymentsInProcing',
				method : 'get'
			}
		});
		
		function getCurrencyOptions() {
			var defer = $q.defer();
			ajaxService.getCurrencyOptions().then(function(response) {
				defer.resolve(response ? response : {});
			});
			return defer.promise;
		};
		
		function getPpfRepaymentStatusOptions() {
			var defer = $q.defer();
			ajaxService.getPpfRepaymentStatusOptions().then(function(response) {
				defer.resolve(response ? response : {});
			});
			return defer.promise;
		};
		
		function getPpfRepaymentsInProcing() {
			var defer = $q.defer();
			ajaxService.getPpfRepaymentsInProcing().then(function(response) {
				defer.resolve(response ? response : {});
			});
			return defer.promise;
		};
		
		function initListSearchOptions() {
			var defer1 = $q.defer();
			var defer2 = $q.defer();
			ajaxService.getCurrencyOptions().then(function(response) {
				defer1.resolve(response ? response.data : {});
			});
			ajaxService.getPpfRepaymentLoadStatusOptions().then(function(response) {
				defer2.resolve(response ? response.data : {});
			});
			return $q.all({
				currencyOptions : defer1.promise,
				ppfRepaymentLoadStatusOptions : defer2.promise
			});
		}
		
		return {
			getCurrencyOptions : getCurrencyOptions,
			getPpfRepaymentStatusOptions : getPpfRepaymentStatusOptions,
			initListSearchOptions : initListSearchOptions,
			getPpfRepaymentsInProcing : getPpfRepaymentsInProcing
		};
	}
})(angular);